-
Notifications
You must be signed in to change notification settings - Fork 252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SuperTextField] Add support for inline widgets (Resolves #2507) #2520
Conversation
SuperTextFieldInspector.findRichText().style!.color, | ||
Colors.orange, | ||
); | ||
for (int i = 0; i <= 9; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there something we can do to make this simpler? Doing this once or twice isn't terrible, but in theory one might want to verify details like text color for any number of cases.
In this particular case, it looks like there's a span per index? That doesn't seem correct. If we have a series of characters with identical styles, they should still be available within a single span, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this particular case, it looks like there's a span per index? That doesn't seem correct. If we have a series of characters with identical styles, they should still be available within a single span, right?
We do have a single span, the goal of this change is to make sure that every character has the same color. If the span at offset zero has the right color, but, somehow, we have other spans with other colors, this test would pass.
We could modify this to ensure that the InlineSpan
has only one child span.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we usually check for exact matches of span markers, which then ensures that only two color markers exist: start and end. And also ensures no other markers exist at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But span markers are at the attributed text level. This is at the Flutter InlineSpan level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. We can leave it as-is.
final inlineWidgetRect = tester.getRect(find.byPlaceholderName('1')); | ||
expect( | ||
inlineWidgetRect.left, | ||
_getOffsetAtPosition(tester, const TextPosition(offset: 5)).dx, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this offset the left side or the right side of the character rectangle?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the left side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then we should probably switch that to the right side, right? If the widget overlaps the final character then that would be a bug.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, offset 5 IS the inline widget. Maybe we should check if it has a bigger offset than the character at offset 4. I update this.
@@ -0,0 +1,412 @@ | |||
import 'package:flutter/gestures.dart'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also have a few golden tests to check caret position, caret height, as well as selection rectangles when selecting over and near inline widgets? These details would be relevant both for single-line text blocks and multi-line text blocks within a text field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added golden tests.
8083e7a
to
8360abc
Compare
[SuperTextField] Add support for inline widgets. Resolves #2507
We already implemented support for inline widgets in
SuperEditor
. This PR adds support for inline widgets inSuperTextField
.We have a
TextSpan buildTextSpan(AttributionStyleBuilder styleBuilder)
method insideAttributedTextEditingController
. This method doesn't seem to belong here, and it isn't being used in the repo. I marked this method as deprecated.